grammar caculator;

stat:(expr)+;
expr: (type? Identifier EQU)? multi_exp ';'# printExpr ;

multi_exp: Identifier                     # id
          |NUM                    #NUM
          | '('multi_exp')'       # multi
          |multi_exp OPMD multi_exp  # calExpr
          |multi_exp OPPM multi_exp # pmExpr
          ;

NUM:(INTVAL|DOUBLEVAL);
INTVAL:[0-9]+;
DOUBLEVAL:[0-9]+'.'[0-9]+;
Identifier  :   LETTER (LETTER)* ;
fragment
LETTER : [a-zA-Z] ;
type:   'float' | 'int'|'double' ;
WS  :   [ \t\n\r]+ -> skip ;

OPPM:PLU|MIN;
OPMD:MUL|DIV;
MUL:'*';
DIV:'/';
PLU:'+';
MIN:'-';
EQU:'=';